package com.joven.shelltest.enums;

import cn.hutool.core.collection.CollectionUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 流量类型
 *
 * @Author wzj
 * @Date 2023-11-08 09:07
 **/
@Getter
@AllArgsConstructor
public enum FluxTypeEnum {

    /**
     * 微信
     */
    WE_CHAT("1", "微信") {
        @Override
        public String getDesc() {
            return "日常上班联系工具";
        }
        @Override
        public FluxTypeEnum link() {
            return QQ;
        }
    },
    /**
     * QQ
     */
    QQ("2", "QQ") {
        @Override
        public String getDesc() {
            return "游戏专用登录方式";
        }
        @Override
        public FluxTypeEnum link() {
            return WE_CHAT;
        }
    },
    /**
     * 微博
     */
    WEI_BO("3", "微博") {
        @Override
        public String getDesc() {
            return "黄图地";
        }
        @Override
        public FluxTypeEnum link() {
            return TIK_TOK;
        }
    },
    /**
     * 小红书
     */
    RED_BOOK("4", "小红书") {
        @Override
        public String getDesc() {
            return "骗子玩意";
        }
        @Override
        public FluxTypeEnum link() {
            return WEI_BO;
        }
    },
    /**
     * 抖音
     */
    TIK_TOK("5", "抖音") {
        @Override
        public String getDesc() {
            return "快乐源泉";
        }
        @Override
        public FluxTypeEnum link() {
            return KUAI_SHOU;
        }
    },
    /**
     * 快手
     */
    KUAI_SHOU("6", "快手") {
        @Override
        public String getDesc() {
            return "智商下降器";
        }
        @Override
        public FluxTypeEnum link() {
            return TIK_TOK;
        }
    },
    /**
     * 知乎
     */
    KNOWN("7", "知乎") {
        @Override
        public String getDesc() {
            return "小作文写作地";
        }
        @Override
        public FluxTypeEnum link() {
            return WEI_BO;
        }
    };

    private final String type;
    private final String name;

    public abstract String getDesc();

    public abstract FluxTypeEnum link();

    public static String getNameByType(String type) {
        List<FluxTypeEnum> fluxTypeEnum = Arrays.stream(FluxTypeEnum.values())
                .filter(it -> it.getType().equals(type))
                .collect(Collectors.toList());
        if (CollectionUtil.isEmpty(fluxTypeEnum)) {
            return StringUtils.EMPTY;
        }
        return fluxTypeEnum.get(0).getName();
    }

    public static FluxTypeEnum getFluxType(String type) {
        return Arrays.stream(FluxTypeEnum.values())
                .filter(it -> it.getType().equals(type))
                .findFirst().orElse(null);
    }


    public static final FluxTypeEnum[] COMMON_TYPE = {WEI_BO, RED_BOOK, TIK_TOK};

}
